package com.dmcloud;

import com.dmcloud.common.util.reponse.ResultMessage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by xiaodao
 * date: 2020/3/28
 */
@RestController
@RequestMapping("/price")
@EnableResourceServer
@EnableDiscoveryClient
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@EnableFeignClients("com.dmcloud")

public class PriceApplication {

    public static void main(String[] args) {
        SpringApplication.run(PriceApplication.class,args);
    }


    @GetMapping("/getUserName/{id}")
    public ResultMessage getUserName(@PathVariable("id") String id, @AuthenticationPrincipal String username){
        System.out.println(username +"from jwt" );
        return ResultMessage.success("成功");
    }


    @GetMapping("/hello/")
    public ResultMessage getUserName(){
        return ResultMessage.success("成功");
    }

}
